package com.justech.mes.utils.plugins.transfer;

import java.lang.annotation.Annotation;
import java.util.List;

/**
 * <h3>Data Format Conversion</h3>
 * <p>
 * Processor is a format converter based on annotation identifier. <br/>
 * Its role is to help developers more easily convert data types and formats <br/>.
 * The main use scenario is to output target data to a weakly typed language environment.
 * </p>
 *
 * @author feifei.li
 */
public interface Processer {


    /**
     * Processing an object
     * <p>Transform the properties of the source object</p>
     *
     * @param source
     * @return
     */
    <T> T process(T source);

    /**
     * Processing a collection of objects
     *
     * @param sources
     * @return
     */
    List<Object> process(List<Object> sources);

    /**
     * Convert to a single type: such as a simple variable.
     * <p> Processors do not parse the structure of the target</p>
     *
     * @param singleType
     * @param annotation
     * @return
     */
    Object processSingleType(Object singleType, Annotation annotation);

    /**
     * Multiprocessing
     *
     * @param singleType
     * @param annotations
     * @return
     */
    Object processSingleType(Object singleType, Annotation[] annotations);

    /**
     * Assemble the transformed data into a collection
     *
     * @param source
     * @return
     */
    List<Object> processToList(Object source);
}
